<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../js/vue.js"></script>
    <style>
        [v-cloak] {
            display: none;
        }

        .tab ul {
            overflow: hidden;
            padding: 0;
            margin: 0;
        }

        .tab ul li {
            box-sizing: border-box;
            padding: 0;
            float: left;
            width: 100px;
            height: 45px;
            line-height: 45px;
            list-style: none;
            text-align: center;
            border-top: 1px solid blue;
            border-right: 1px solid blue;
            cursor: pointer;
        }

        .tab ul li:first-child {
            border-left: 1px solid blue;
        }

        .tab ul li.active {
            background-color: orange;
        }

        .tab div {
            width: 600px;
            height: 400px;
            display: none;
            text-align: center;
            font-size-adjust: 30px;
            line-height: 300px;
            border: 1px solid blue;
            border-top: 0px;
        }

        img {
            width: 600px;
            height: 400px;
        }

        .tab div.current {
            display: block;
        }

        #app {
            min-height: 500px;
            display: flex;
            justify-content: center;
            align-content: center;
            align-items: center;
        }
    </style>
</head>

<body>

    <dvi id="app">
        <div class="tab">
            <!-- 原生语法 -->
            <ul>
                <!-- <li class="active">apple</li>
                <li>orange</li>
                <li>lemon</li> -->
            </ul>
            <!-- <div class="current">
                <img src="../../img/test/11.jpg">
            </div>
            <div>
                <img src="../../img/test/22.jpg">
            </div>
            <div>
                <img src="../../img/test/33.jpg">
            </div> -->

            <!-- 使用Vue语法 -->
            <ul>
                <li @click="change(index)" :class="currentIndex==index ? 'active': ''" v-for="(item, index) in list"
                    :key="item.id">{{item.title}}
                </li>
            </ul>
            <div :class="currentIndex==index ? 'current': ''" v-for="(item, index) in list" :key="item.id">
                <img :src="item.path">
            </div>
        </div>

    </dvi>

    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                list: [{
                    title: "apple",
                    id: 1,
                    path: "../../img/test/11.jpg"
                }, {
                    title: "orange",
                    id: 1,
                    path: "../../img/test/22.jpg"
                }, {
                    title: "lemon",
                    id: 1,
                    path: "../../img/test/33.jpg"
                }],
                currentIndex: 0,
            },
            methods: {
                change(index) {
                    this.currentIndex = index;
                }
            }
        })
    </script>
</body>

</html>